const apiBaseUrl = "https://api.xunyi.mobi/api/v1/";
const qiniuDomain = 'http://static.duyoucai.com';
const cdnUrl = 'http://static.xunyi.mobi/';
const apiUrls = {
  getCategories: apiBaseUrl + 'tool/categories?pid=2',
  getAreas: apiBaseUrl + 'tool/areas',
  getQiniuToken: apiBaseUrl + 'tool/qiniu_token',
  postApplyItem: apiBaseUrl + 'user/apply_item',
  getShopList: apiBaseUrl + 'items',
  getUserInfo: apiBaseUrl + 'user/info',
  getMyStore: apiBaseUrl + 'user/items',  
  getShopDetail(id) {
    return apiBaseUrl + 'items/' + id
  },
  /*
  *更新  put
  */
  // Address
  putAddressEdit(id) {
    return apiBaseUrl + 'item/' + id + '/address'
  },
  // Cover
  putCoverEdit(id) {
    return apiBaseUrl + 'item/' + id + '/cover'
  },
  // Logo
  putLogoEdit(id) {
    return apiBaseUrl + 'item/' + id + '/logo'
  },
  // 店铺名称
  putNameEdit(id) {
    return apiBaseUrl + 'item/' + id + '/name'
  },
  // 营业时间
  putTimeEdit(id) {
    return apiBaseUrl + 'item/' + id + '/time'
  },
  // 自动切换
  putFollowEdit(id) {
    return apiBaseUrl + 'item/' + id + '/follow'
  },
  // 手动切换
  putStatusEdit(id) {
    return apiBaseUrl + 'item/' + id + '/status'
  },
  // 分类
  putCategoryEdit(id) {
    return apiBaseUrl + 'item/' + id + '/category'
  },
  // 营业执照
  putBusiness_licencesEdit(id) {
    return apiBaseUrl + 'item/' + id + '/business_licences'
  },
  // 热销商品
  putPhotosEdit(id) {
    return apiBaseUrl + 'item/' + id + '/photos'
  },
}

function makeRequest(option) {
  const ak = wx.getStorageSync('ak');
  const optionNew = Object.assign(option, { header: { Authorization: 'Bearer ' + ak, Accept: 'application/json' } });
  wx.request(optionNew);
}

module.exports = {
  apiBaseUrl,
  cdnUrl,
  apiUrls: apiUrls,
  makeRequest: makeRequest
}